﻿<window:MetroDPIWindow x:Class="CircuitDiagram.winComponents"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:CircuitDiagram"
        xmlns:window="clr-namespace:CircuitDiagram.DPIWindow;assembly=CircuitDiagram.DPIWindow"
        Title="Components" Height="385" Width="600" ShowInTaskbar="False" ResizeMode="NoResize"
        WindowStartupLocation="CenterOwner" TitleCaps="False" WindowTransitionsEnabled="False" EnableDWMDropShadow="True">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <my:BoolToYesNoConverter x:Key="YesNoConverter" />
            <my:EmbedByDefaultConverter x:Key="EmbedByDefaultConverter" />
            <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <my:SignatureToColourConverter x:Key="SignatureToColourConverter" />
            <my:SignatureToFontWeightConverter x:Key="SignatureToFontWeightConverter" />
            <my:SignatureStatusConverter x:Key="SignatureStatusConverter" />
            <my:MultiResolutionImageToImageSourceConverter x:Key="MultiResolutionImageToImageSourceConverter" />
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <ListBox HorizontalAlignment="Left" Margin="12,12,0,41" Name="lbxComponents" Width="163" DisplayMemberPath="ComponentName" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" />
        <Button Content="Close" Height="23" HorizontalAlignment="Right" Margin="0,0,12,12" Name="btnClose" VerticalAlignment="Bottom" Width="75" Click="btnClose_Click" IsCancel="True" />
        <Grid Margin="181,12,12,41">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120*" />
                <ColumnDefinition Width="210*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
                <RowDefinition Height="45" />
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
                <RowDefinition Height="27" />
            </Grid.RowDefinitions>
            <Label Name="lblName" Grid.Column="0" Grid.Row="0">Name</Label>
            <Label Name="lblAuthor" Grid.Column="0" Grid.Row="1">Author</Label>
            <Label Name="lblEmbedByDefault" Grid.Column="0" Grid.Row="2">Embed by default</Label>
            <Label Name="lblType" Grid.Column="0" Grid.Row="3">Type</Label>
            <Label Name="lblIcon" Grid.Column="0" Grid.Row="4" VerticalAlignment="Center">Icon</Label>
            <Label Name="lblGuid" Grid.Column="0" Grid.Row="5">GUID</Label>
            <Label Name="lblVersion" Grid.Column="0" Grid.Row="6">Version</Label>
            <Label Name="lblAdditionalInfo" Grid.Column="0" Grid.Row="7">Additional information</Label>
            <Label Name="lblLocation" Grid.Column="0" Grid.Row="8">Location</Label>
            <Label Name="lblSigned" Grid.Column="0" Grid.Row="9">Signed</Label>

            <Label Grid.Column="1" Grid.Row="0" Content="{Binding Path=ComponentName}" />
            <Label Grid.Column="1" Grid.Row="1" Content="{Binding Path=Metadata.Author}" 
                   Foreground="{Binding Path=Metadata.Signature, Converter={StaticResource SignatureToColourConverter}}"
                   FontWeight="{Binding Path=Metadata.Signature, Converter={StaticResource SignatureToFontWeightConverter}}" />
            <Label Grid.Column="1" Grid.Row="2" Content="{Binding ElementName=lbxComponents, Path=SelectedItem, Converter={StaticResource EmbedByDefaultConverter}}" />
            <Grid Grid.Column="1" Grid.Row="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Content="{Binding Path=Metadata.Type}" />
                <Label Name="lblComponentDetails" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                    <Hyperlink Name="lnkComponentDetails" Click="hyperlinkComponentDetails_Click">Details</Hyperlink>
                </Label>
            </Grid>
            <Rectangle Fill="White" Width="32" Height="32" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Left">
                <Rectangle.OpacityMask>
                    <ImageBrush ImageSource="{Binding Path=Metadata.Icon, Converter={StaticResource MultiResolutionImageToImageSourceConverter}}" />
                </Rectangle.OpacityMask>
            </Rectangle>
            <Label Grid.Column="1" Grid.Row="5" Content="{Binding Path=Metadata.GUID}" />
            <Label Grid.Column="1" Grid.Row="6" Content="{Binding Path=Metadata.Version}" />
            <Label Grid.Column="1" Grid.Row="7" Content="{Binding Path=Metadata.AdditionalInformation}" />
            <Label Grid.Column="1" Grid.Row="8" Content="{Binding Path=Metadata.Location}" />
            <Grid Grid.Column="1" Grid.Row="9">
                <Label Content="{Binding Path=Metadata.Signature, Converter={StaticResource SignatureStatusConverter}}" 
                       Foreground="{Binding Path=Metadata.Signature, Converter={StaticResource SignatureToColourConverter}}"
                       FontWeight="{Binding Path=Metadata.Signature, Converter={StaticResource SignatureToFontWeightConverter}}" />
                <Label Name="lblViewCertificate" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Visibility="{Binding Path=Metadata.Signature.IsSigned, Converter={StaticResource BoolToVisibilityConverter}}">
                    <Hyperlink Name="lnkViewCertificate" Click="lnkViewCertificate_Click">View certificate</Hyperlink>
                </Label>
            </Grid>

        </Grid>
        <Label Name="lblMoreComponents" Margin="0,0,93,9" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="136">
            <Hyperlink Name="lnkMoreComponents" Click="hyperlinkGetMoreComponents_Click">Get more components</Hyperlink>
        </Label>
        <Label Name="lblComponentsFolder" Margin="10,0,0,9" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="136">
            <Hyperlink Name="lnkComponentsFolder" Click="hyperlinkComponentsFolder_Click">Components folder</Hyperlink>
        </Label>
    </Grid>
</window:MetroDPIWindow>
